package edu.udo.sopra10.chaturaji.entities.terminationconditions;

import edu.udo.sopra10.chaturaji.entities.Game;

/**
 * {@link Game} termination after a limit has been reached or
 * {@link TotalElimination} occurs.
 * 
 * @author Simon Dierl
 */
abstract class Limit extends TotalElimination {
	/**
	 * The game's round limit.
	 */
	protected int limit;

	/**
	 * Create a new {@link Limit} for the specified {@link Game}.
	 * 
	 * @param game
	 *            the terminated game, may be {@code null} if not created.
	 * @param limit
	 *            the limit, must be {@code > 0}.
	 */
	public Limit(final Game game, final int limit) {
		super(game);
		setLimit(limit);
	}

	/**
	 * Get the game's limit.
	 * 
	 * @return the limit, always {@code > 0}.
	 */
	public int getLimit() {
		return limit;
	}

	/**
	 * Set the game's limit.
	 * 
	 * @param limit
	 *            the new limit, must be {@code > 0}.
	 */
	public void setLimit(final int limit) {
		if (limit <= 0) {
			throw new IllegalArgumentException("limit must be > 0");
		}
		this.limit = limit;
	}
}
